import json
from pathlib import Path

file_path = Path(__file__).parent / "data.json"

json_data = {"name": "张三", "age": 25, "cities": ["北京", "上海", "广州"]}

with open(file_path, "w", encoding="utf-8") as jsonfile:

    json.dump(json_data, jsonfile, ensure_ascii=False, indent=4)


# 读取 JSON 文件
with open(file_path, "r", encoding="utf-8") as file:
    loaded_data = json.load(file)
    print(loaded_data)
